package com.mvc4g.example.client.company.views;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.mvc4g.client.Event;
import com.mvc4g.example.client.company.CompanyBean;

public class DisplayCompanyView extends AbstractCompanyView {

	private Label name = null;
	private Label address = null;
	private CompanyBean company = null;
	
	protected void finishCreation(){
		name = new Label();
		address = new Label();
		grid.setWidget(0, 1, name);
		grid.setWidget(1, 1, address);
	}

	public void init(CompanyBean company) {
		this.company = company;
		name.setText(company.getName());
		address.setText(company.getAddress());
	}

	protected Widget getLastName() {
		if(name == null){
			name = new Label();
		}
		return name;
	}

	protected Widget getFirstName() {
		if(address == null){
			address = new Label();
		}
		return address;
	}

	protected String getButtonText() {
		return "Copy";
	}

	protected void buttonAction() {
		controller.handleEvent(new Event(COPY_COMPANY, company));
	}

}
